package com.hmall.search.controller;


import com.hmall.common.domain.PageDTO;
import com.hmall.search.domain.Dto.ItemDTO;
import com.hmall.search.domain.ItemPageQuery;
import com.hmall.search.domain.vo.SearchVo;
import com.hmall.search.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;


import org.springframework.web.bind.annotation.*;

@Api(tags = "搜索相关接口")
@RestController
@RequestMapping("/search")
@RequiredArgsConstructor
public class SearchController {
    private final SearchService searchService;
    @ApiOperation("搜索商品")
    @GetMapping("/list")
    public PageDTO<ItemDTO> search(ItemPageQuery query)throws  Exception{
        // 分页查询
        return searchService.search(query);
        // 封装并返回

    }
    @ApiOperation("生成过滤条件")
    @PostMapping("/Filters")
    public SearchVo filters(@RequestBody ItemPageQuery query) throws Exception {
        return searchService.filters(query);

    }
}
